package com.kbbywyclient.util;

import com.kbbywyclient.app.App;
import com.kbbywyclient.app.Key;

import java.util.HashMap;
import java.util.Map;

import javax.inject.Inject;

/**
 * 参数加密 工具类
 * Created by FHW
 * on 2017/3/24
 */

public class RsaJsonUtil {
    private Map<String, Object> map = null;

    @Inject
    public RsaJsonUtil() {
        map = new HashMap<>();
    }

    public String getRsaParams() {
        map.put("Token", MD5Utils.md5(StringUtil.getDeviceId(App.getInstance())));
        String rsaParams = "";
        try {
            rsaParams = JsonAndObject.object2Json(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        LogUtil.d(rsaParams);//打印未加密的参数
        map.clear();
        return RSAUtil.encryptByPublicKey(rsaParams, Key.publicKey);
    }

    public void put(String key, Object o) {
        map.put(key, o);
    }
}
